package com.kefu.call.vo;

import org.apache.commons.lang3.StringUtils;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.kefu.common.context.KefuContext;
import com.kefu.common.vo.AbstractSearchVo;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;

/**
 * @author francis
 * @date 2021/05/22
 */
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
@ApiModel(description = "活动管理")
public class ActivityBaseInfoSearchVo extends AbstractSearchVo {

	@ApiModelProperty(value = "创建时间开始")
    private Long createTimeStart;
    @ApiModelProperty(value = "创建时间结束")
    private Long createTimeEnd;
    @ApiModelProperty(value = "活动名称")
    private String activityName;
    @ApiModelProperty(value = "活动类型",example="1",allowableValues="1",notes="1 外呼活动")
    private Integer activityType;
    @ApiModelProperty(value = "活动状态",example="1",allowableValues="0,1,2,3",notes="0 未启用，1启用，2暂停，3 停止")
    private Integer activityStatus;
    @ApiModelProperty(value = "是否隐藏号码",allowableValues="0,1",notes="0 不隐藏号码，1隐藏号码")
    private Integer hiddenNum;
    @ApiModelProperty(hidden = true)
	private String tenantId;

    public <T>QueryWrapper<T> builder() {
 		QueryWrapper<T> wrapper=Wrappers.query();
        if (createTimeStart != null) {
        	wrapper.ge("create_time", createTimeStart);
		}
		if (createTimeEnd != null) {
			wrapper.le("create_time", createTimeEnd);
		}
	    if (StringUtils.isNotBlank(activityName)) {
	        wrapper.eq("activity_name", activityName);
	    }
		if (activityType != null) {
		    wrapper.eq("activity_type", activityType);
		}
		if (activityStatus != null) {
		    wrapper.eq("activity_status", activityStatus);
		}
		if (hiddenNum != null) {
		    wrapper.eq("hidden_num", hiddenNum);
		}
	    wrapper.eq("tenant_id", KefuContext.getKefuContext().getTenantId());
	    return wrapper;
	}
}